<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue事件基本使用</title>
    <script type="text/javascript" src="../../js/vue.js"></script>

</head>
<body>
    <div id="root">
        <h4>测试{{name}}</h4>
        <!-- <button v-on:click="showInfo">点击事件</button> -->
        <button @click="showInfo">点击事件</button>
        <button @click="showInfo2(121)">点击事件2</button>
        
    </div>

    <script type="text/javascript">
        Vue.config.performance = false;

        
        const vm = new Vue({
            el:'#root',
            data() {
                return {
                    name: 'zw',
                };
            },
            methods:{
                showInfo(event) {
                    //alert('点击事件')
                    console.log(event)
                    console.log(this == vm) // true
                },
                /*  showInfo:(event) => {
                    //alert('点击事件')
                    console.log(this)
                    console.log(this == vm) // false,此处的this为window
                } */
                showInfo2(number,e) {
                    console.log(event.target.innerText)
                    alert(number)
                }
               
            }
        
        })

    </script>

</body>
</html>